clear all
set more 1
set maxvar 120000
set matsize 11000

******************************************************************************;
******************************************************************************;
******************************************************************************;
*Empirical Analysis;
*This part of the code replicates the empirical tables and figures in the paper:
*Figure 1: Authoritarian Parenting and Neighborhood Characteristics
*Appendix Figure A-1: Correlation between Parent and Child Reported Measure of Authoritarian Parenting
*Appendix Figure A-2: Parenting Style and Neighborhood;

*Table 1: Authoritarian Parenting and Peer Environment within Schools;
*Table 2: Authoritarian Parenting and Academic Achievement of Friends (Child Fixed Effects) 
*Table 3: Authoritarian Parenting and Dynamics of the Academic Achievement of Peers
*Appendix Table A-1: Summary Statistics
*Appendix Table A-2: Authoritarian Parenting and Peer Environment Across Schools;
*Appendix Table A-3: Authoritarian Parenting and Peer Environment within Schools (Gini)
*Appendix Table A-4: Authoritarian Parenting and Peer Environment within Schools (by Gender);
*Appendix Table A-5: Authoritarian Parenting (Index) and Peer Environment within Schools
*Appendix Table A-6: Authoritarian Parenting and Dynamics of Peer Achievement(Index Measure)
******************************************************************************;
******************************************************************************;
******************************************************************************;

*************************************************;
*Set global directories;
*************************************************;

global main            = ""
global data            = ""
global figures         = ""
global tables          = ""
global do              = ""
global scratch         = ""
global scratch_large   = ""
global matlab_dir      = ""
global paper_dir       = ""
global matlab_dir_boot = ""


******************************************************************************;
*Load, Merge and Clean Data;
******************************************************************************;

local do_here = 0

if `do_here'==1{
do $do/1.key_variables.do
}


******************************************************************************;
*Construct Friendships and Compute Skills for Peers;
******************************************************************************;

local do_here = 0

if `do_here'==1{
do $do/2.skills_peers.do
}

******************************************************************************;
*Figure 1: Authoritarian Parenting and Neighborhood Characteristics
*Appendix Figure A-1: Correlation between Parent and Child Reported Measure of Authoritarian Parenting
*Appendix Figure A-2: Parenting Style and Neighborhood;
*Appendix Table A-2: Authoritarian Parenting and Peer Environment Across Schools;
******************************************************************************;
local do_here = 1

if `do_here'==1{

do $do/3.figures1_A1-2.do

do $do/3b.tableA2.do
}

******************************************************************************;
*Table 1: Authoritarian Parenting and Peer Environment within Schools;
*Appendix Table A-3: Authoritarian Parenting and Peer Environment within Schools (Gini)
*Appendix Table A-4: Authoritarian Parenting and Peer Environment within Schools (by Gender);
*Appendix Table A-5: Authoritarian Parenting (Index) and Peer Environment within Schools
******************************************************************************;
local do_here = 0

if `do_here'==1{
do $do/4.table1_A3-5.do
}

******************************************************************************;
*Table 2: Authoritarian Parenting and Academic Achievement of Friends (Child Fixed Effects) 
*Table 3: Authoritarian Parenting and Dynamics of the Academic Achievement of Peers
*Appendix Table A-6: Authoritarian Parenting and Dynamics of Peer Achievement(Index Measure)
******************************************************************************;
local do_here = 0

if `do_here'==1{
do $do/5.table2_3_A6.do
}

******************************************************************************;
*Appendix Table A-1: Summary Statistics
******************************************************************************;
local do_here = 0

if `do_here'==1{
do $do/6.tableA1.do
}





******************************************************************************;
******************************************************************************;
******************************************************************************;
*Construction of Empirical Moments Used for the Estimation of the Model;
******************************************************************************;
******************************************************************************;
******************************************************************************;


******************************************************************************;
*Measurement model in Appendix Equation B-1 and generates Table B-1
******************************************************************************;
local do_here = 0

if `do_here'==1{
do $do/7.skills_measurement.do
}


******************************************************************************;
*Initial Conditions for the Model;
******************************************************************************;
local do_here = 0

if `do_here'==1{

***********;
*Table 4 (base model);
***********;
do $do/8.initial_conditions.do

*Model with parental education (college);
do $do/8b.initial_conditions_educ.do
}

******************************************************************************;
*Construct Empirical Moments for the Estimation of the Model;
******************************************************************************;
local do_here = 0

if `do_here'==1{

***********;
*Base model;
***********;
do $do/9.moments.do

*Model with parental education (college);
do $do/9.moments_educ.do
}


******************************************************************************;
*Bootstrap of the Empirical Moments for the Estimation of the Model;
******************************************************************************;

local do_here = 0

if `do_here'==1{
do $do/10.bootstrap_moments.do
}

